<?php 
class Goodsmapcpt extends CS_Controller
{
    public function _init()
    {
        $this->load->library('pagination');
        $this->load->model('goods_map_cpt_model', 'goods_map_cpt');
    }
    
    public function grid($pg = 1)
    {
        $page_num = 60;
        $num = ($pg-1)*$page_num;
        $config['per_page'] = $page_num;
        $config['first_url'] = base_url('goodsmapcpt/grid').$this->pageGetParam($this->input->get());
        $config['suffix'] = $this->pageGetParam($this->input->get());
        $config['base_url'] = base_url('goodsmapcpt/grid');
        $config['total_rows'] = $this->goods_map_cpt->total($this->input->get());
        $config['uri_segment'] = 3;
        $this->pagination->initialize($config);
        $data['pg_link'] = $this->pagination->create_links();
        $data['page_list'] = $this->goods_map_cpt->page_list($page_num, $num, $this->input->get());
        $data['all_rows'] = $config['total_rows'];
        $data['pg_now'] = $pg;
        $this->load->view('goodsmapcpt/grid', $data);
    }
    
    public function delete($goods_id=0, $uid=0)
    {
        $params = array('goods_id'=>$goods_id, 'uid'=>$uid);
        $is_delete = $this->goods_map_cpt->delete(array('goods_id'=>$goods_id, 'uid'=>$uid));
        if ($is_delete) {
            $this->success('goodsmapcpt/grid', array('goods_id'=>$goods_id), '删除成功！');
        } else {
            $this->error('goodsmapcpt/grid', array('goods_id'=>$goods_id), '删除失败！');
        }
    }
}